home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGMISC
/
FORTRAN2.LZH
/
STD.FOR
< prev
next >
Wrap
Text File
|
1988-02-08
|
7KB
|
207 lines
SUBROUTINE STD ( FACTS, TOKE, NTOKE, ERR )
C*
C* *******************************
C* *******************************
C* ** **
C* ** STD **
C* ** **
C* *******************************
C* *******************************
C*
C* SUBPROGRAM :
C* STANDARDIZE
C*
C* AUTHOR :
C* ART RAGOSTA
C* MS 207-5
C* AMES RESEARCH CENTER
C* MOFFETT FIELD, CALIF 94035
C* (415) 694-5578
C*
C* PURPOSE :
C* TO REPLACE NON-STANDARD UNITS WITH THEIR EQUIVALENT
C* STANDARD UNITS AND RESULTING SCALE FACTOR.
C*
C* METHODOLOGY :
C* NA
C*
C* INPUT ARGUMENTS :
C* TOKE - ARRAY OF (POTENTIALLY) NON-STANDARD UNITS
C* NTOKE - NUMBER OF ENTRIES IN TOKE
C*
C* OUTPUT ARGUMENTS :
C* TOKE - THE ARRAY WITH ONLY STANDARD UNITS
C* NTOKE - NUMBER OF ENTRIES IN TOKE
C* FACTS - ARRAY WITH SCALE FACTORS FOR EACH UNIT IN TOKE
C* ERR - SET TRUE IF A UNIT COULD NOT BE FOUND
C*
C* INTERNAL WORK AREAS :
C* TEMP - USED TO STORE TOKENS UNTIL ALL UNITS ARE REPLACED
C*
C* COMMON BLOCKS :
C* NONE
C*
C* FILE REFERENCES :
C* NONE
C*
C* SUBPROGRAM REFERENCES :
C* NONE
C*
C* ERROR PROCESSING :
C* IF A UNIT ISN'T FOUND, ABORT.
C*
C* TRANSPORTABILITY LIMITATIONS :
C* NONE
C*
C* ASSUMPTIONS AND RESTRICTIONS :
C* NONE
C*
C* LANGUAGE AND COMPILER :
C* ANSI FORTRAN 77
C*
C* VERSION AND DATE :
C* VERSION I.0 7-FEB-85
C*
C* CHANGE HISTORY :
C* 7-FEB-85 INITIAL VERSION
C*
C***********************************************************************
C*
PARAMETER (NUM=39)
CHARACTER *6 TOKE(1), TEMP(100), KNOWN(NUM), ALIAS(NUM),
$ LIST(100)
CHARACTER *1 FIRST
LOGICAL ERR
DOUBLE PRECISION FACTS(1), KFACT(NUM)
C
C --- KNOWN UNITS (BOTH STANDARD AND NON-STANDARD)
C
C --- NOTE: THE FOLLOWING ARRAY MUST BE IN ALPHABETIC ORDER
C
DATA KNOWN / 'CM ', 'FEET ', 'FPS ', 'FT ',
$ 'GAL ', 'GALLON', 'GM ', 'GRAM ', 'HOUR ',
$ 'HP ', 'HR ', 'IN ', 'INCH ', 'KG ',
$ 'KILOGR', 'KILOME', 'KM ', 'KNOTS ', 'L ',
$ 'LB ', 'LITER ', 'M ', 'METER ', 'MI ',
$ 'MILE ', 'MIN ', 'MINUTE', 'MPH ', 'N ',
$ 'NAUTMI', 'NEWTON', 'POUND ', 'PSI ', 'S ',
$ 'SEC ', 'SECOND', 'SLUG ', 'YD ', 'YARD '/
C
C --- THE CONVERSION FACTOR TO GET FROM 'KNOWN' TO 'ALIAS'
C
C --- IMPORTANT!!! THE CONVERSION FACTORS FOR 'GAL' AND 'LITER' ARE
C --- THE CUBE ROOT OF THE ACTUAL CONVERSION FACTOR SINCE 'EVAL' WILL
C --- CUBE THEM WHEN IT SEES 'FT^3'.
C
DATA KFACT / 3.28084D-2, 1.0D0, 1.0D0, 1.0D0,
$5.11317368D-1,5.11317368D-1,6.852166D-5, 6.852166D-5, 3.6D3,
$5.5D2, 3.6D3, 8.3333333D-2,8.3333333D-2,6.852166D-2,
$6.852166D-2, 3.28084D3, 3.28084D3, 1.68780648D0,3.2808719D-2,
$1.0D0, 3.2808719D-2,3.28084D0, 3.28084D0, 5.28D3,
$5.28D3, 6.0D1, 6.0D1, 1.4666667D0, 2.2046226D0,
$6.0761157D3, 2.2046226D0, 1.0D0, 6.9444444D-3,1.0D0,
$1.0D0, 1.0D0, 1.0D0, 3.0D0, 3.0D0/
C
C --- THE EQUIVALENT STANDARD UNIT OR POINTER INTO 'LIST'
C
DATA ALIAS / 'FT ', 'FT ', '- 21', 'FT ',
$ '- 27', '- 27', 'SLUG ', 'SLUG ', 'SEC ',
$ '- 1', 'SEC ', 'FT ', 'FT ', 'SLUG ',
$ 'SLUG ', 'FT ', 'FT ', '- 9', '- 33',
$ 'LB ', '- 33', 'FT ', 'FT ', 'FT ',
$ 'FT ', 'SEC ', 'SEC ', '- 15', 'LB ',
$ 'FT ', 'LB ', 'LB ', '- 39', 'SEC ',
$ 'SEC ', 'SEC ', 'SLUG ', 'FT ', 'FT '/
C
C --- THIS LIST IS USED WHEN A NON-STANDARD UNIT MUST BE REPLACED BY A
C --- LIST OF STANDARD UNITS (EG, 'HP' = 'FT-LB/SEC')
C
DATA LIST / '( ', 'FT ', '* ', 'LB ',
$ '/ ', 'SEC ', ') ', '$ ', '( ',
$ 'FT ', '/ ', 'SEC ', ') ', '$ ',
$ '( ', 'FT ', '/ ', 'SEC ', ') ',
$ '$ ', '( ', 'FT ', '/ ', 'SEC ',
$ ') ', '$ ', '( ', 'FT ', '^ ',
$ '3 ', ') ', '$ ', '( ', 'FT ',
$ '^ ', '3 ', ') ', '$ ', '( ',
$ 'LB ', '/ ', 'FT ', '^ ', '2 ',
$ ') ', '$ ',
$ 54*' '/
C
ITOKE = 1
IFAC = 1
DO 100 I = 1, NTOKE
C
C --- IF THE TOKEN REPRESENTS A UNIT, BINARY SEARCH UNITS LIST
C
FIRST = TOKE(I)(1:1)
IF ((FIRST .GE. 'A') .AND. (FIRST .LE. 'Z')) THEN
C
C --- BINARY SEARCH KNOWN UNITS LIST
C
II = 1
J = NUM
10 K = (II + J) / 2
IF (TOKE(I) .LE. KNOWN(K)) J = K - 1
IF (TOKE(I) .GE. KNOWN(K)) II = K + 1
IF (II .LE. J) GO TO 10
IF (II-1 .LE. J) THEN
C
C --- IF NOT FOUND, SET ERROR AND RETURN
C
ERR = .TRUE.
RETURN
ENDIF
C
C --- FOUND... PUT IN SCALE FACTOR (1 IF ALREADY STANDARD)
C --- IF NOT STANDARD, PACK REPLACEMENT UNITS IN TEMP
C
IF (ALIAS(K)(1:1) .EQ. '-') THEN
READ(ALIAS(K)(2:6),900) IPTR
ISTORE = IFAC
20 FACTS(IFAC) = 1.0D0
IFAC = IFAC + 1
TEMP(ITOKE) = LIST(IPTR)
ITOKE = ITOKE + 1
IPTR = IPTR + 1
IF (LIST(IPTR) .NE. '$') GO TO 20
FACTS(ISTORE+1) = KFACT(K)
ELSE
FACTS(IFAC) = KFACT(K)
IFAC = IFAC + 1
TEMP(ITOKE) = ALIAS(K)
ITOKE = ITOKE + 1
ENDIF
C
C --- IF THE TOKEN IS A NUMBER (EXPONENT) PASS A 1.
C --- (THIS IS NEEDED SINCE 'EVAL' PASSES EXPONENTS TO THE STACK
C
ELSE IF((FIRST .GE. '0') .AND. (FIRST .LE. '9')) THEN
TEMP(ITOKE) = TOKE(I)
ITOKE = ITOKE + 1
FACTS(IFAC) = 1.0D0
IFAC = IFAC + 1
C
C --- OTHERWISE, ITS AN OPERATOR
C
ELSE
TEMP(ITOKE) = TOKE(I)
ITOKE = ITOKE + 1
FACTS(IFAC) = 1.0D0
IFAC = IFAC + 1
ENDIF
100 CONTINUE
C
C --- COPY FROM TEMP STORAGE BACK TO TOKE
C
NTOKE = ITOKE - 1
DO 200 I = 1, NTOKE
TOKE(I) = TEMP(I)
200 CONTINUE
RETURN
900 FORMAT(I5)
END
C
C---END STD
C